package c.h.a.m0.r;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.DhcpInfo;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.telephony.CellLocation;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Base64;
import android.util.SparseArray;
import c.j.a.c.g.m;
import c.j.a.c.g.n;
import c.j.a.c.g.y;
import c.j.a.d.a.i;
import c.j.a.d.b.e.d;
import c.j.a.d.b.e.p;
import c.j.a.d.b.j.q;
import com.google.android.gms.dynamite.descriptors.com.google.android.gms.measurement.dynamite.ModuleDescriptor;
import com.liuzh.deviceinfo.DeviceInfoApp;
import com.pgl.sys.ces.out.ISdkLite;
import com.ss.android.socialbase.downloader.g.c;
import com.ss.android.socialbase.downloader.g.e;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.zip.ZipFile;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.json.JSONObject;

/* compiled from: NetworkUtils */
public class a {
    public static m a;
    public static n b;

    public static String A(int i) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(i & ISdkLite.REGION_UNSET);
        String str = ".";
        stringBuilder.append(str);
        stringBuilder.append((i >> 8) & ISdkLite.REGION_UNSET);
        stringBuilder.append(str);
        stringBuilder.append((i >> 16) & ISdkLite.REGION_UNSET);
        stringBuilder.append(str);
        stringBuilder.append((i >> 24) & ISdkLite.REGION_UNSET);
        return stringBuilder.toString();
    }

    public static boolean B() {
        int x = x();
        return x == 1 || x == 2 || x == 3 || x == 4;
    }

    /* JADX WARNING: Missing exception handler attribute for start block: B:14:0x003a */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:15:?, code skipped:
            r2 = android.telephony.TelephonyManager.class.getMethod("isMultiSimEnabled", new java.lang.Class[0]);
            r2.setAccessible(true);
     */
    /* JADX WARNING: Missing block: B:16:0x0053, code skipped:
            return ((java.lang.Boolean) r2.invoke(r0, new java.lang.Object[0])).booleanValue();
     */
    /* JADX WARNING: Missing block: B:17:0x0054, code skipped:
            return false;
     */
    public static boolean C() {
        /*
        r0 = com.liuzh.deviceinfo.DeviceInfoApp.c;
        r1 = "phone";
        r0 = r0.getSystemService(r1);
        r0 = (android.telephony.TelephonyManager) r0;
        r1 = 0;
        if (r0 != 0) goto L_0x000e;
    L_0x000d:
        return r1;
    L_0x000e:
        r2 = android.os.Build.VERSION.SDK_INT;
        r3 = 23;
        r4 = 1;
        if (r2 < r3) goto L_0x001d;
    L_0x0015:
        r0 = r0.getPhoneCount();
        if (r0 <= r4) goto L_0x001c;
    L_0x001b:
        r1 = 1;
    L_0x001c:
        return r1;
    L_0x001d:
        r2 = android.telephony.TelephonyManager.class;
        r3 = "getSimCount";
        r5 = new java.lang.Class[r1];	 Catch:{ Exception -> 0x003a }
        r2 = r2.getMethod(r3, r5);	 Catch:{ Exception -> 0x003a }
        r2.setAccessible(r4);	 Catch:{ Exception -> 0x003a }
        r3 = new java.lang.Object[r1];	 Catch:{ Exception -> 0x003a }
        r2 = r2.invoke(r0, r3);	 Catch:{ Exception -> 0x003a }
        r2 = (java.lang.Integer) r2;	 Catch:{ Exception -> 0x003a }
        r0 = r2.intValue();	 Catch:{ Exception -> 0x003a }
        if (r0 <= r4) goto L_0x0039;
    L_0x0038:
        r1 = 1;
    L_0x0039:
        return r1;
    L_0x003a:
        r2 = android.telephony.TelephonyManager.class;
        r3 = "isMultiSimEnabled";
        r5 = new java.lang.Class[r1];	 Catch:{ Exception -> 0x0054 }
        r2 = r2.getMethod(r3, r5);	 Catch:{ Exception -> 0x0054 }
        r2.setAccessible(r4);	 Catch:{ Exception -> 0x0054 }
        r3 = new java.lang.Object[r1];	 Catch:{ Exception -> 0x0054 }
        r0 = r2.invoke(r0, r3);	 Catch:{ Exception -> 0x0054 }
        r0 = (java.lang.Boolean) r0;	 Catch:{ Exception -> 0x0054 }
        r0 = r0.booleanValue();	 Catch:{ Exception -> 0x0054 }
        return r0;
    L_0x0054:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.h.a.m0.r.a.C():boolean");
    }

    public static boolean D() {
        return x() == 5 && z() != null;
    }

    public static long a(JSONObject jSONObject, String str) {
        try {
            return Long.valueOf(jSONObject.optString(str)).longValue();
        } catch (NumberFormatException unused) {
            return 0;
        }
    }

    @SuppressLint({"PrivateApi"})
    public static Activity b() {
        try {
            Class cls = Class.forName("android.app.ActivityThread");
            Object invoke = cls.getMethod("currentActivityThread", new Class[0]).invoke(null, new Object[0]);
            Field declaredField = cls.getDeclaredField("mActivities");
            declaredField.setAccessible(true);
            ArrayMap arrayMap = (ArrayMap) declaredField.get(invoke);
            if (arrayMap.size() < 1) {
                return null;
            }
            for (Object invoke2 : arrayMap.values()) {
                Class cls2 = invoke2.getClass();
                Field declaredField2 = cls2.getDeclaredField("paused");
                declaredField2.setAccessible(true);
                if (!declaredField2.getBoolean(invoke2)) {
                    declaredField = cls2.getDeclaredField("activity");
                    declaredField.setAccessible(true);
                    return (Activity) declaredField.get(invoke2);
                }
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static String c(BufferedInputStream bufferedInputStream) {
        byte[] bArr = new byte[4096];
        StringBuilder stringBuilder = new StringBuilder();
        int read;
        do {
            try {
                read = bufferedInputStream.read(bArr);
                if (read > 0) {
                    stringBuilder.append(new String(bArr, 0, read));
                    continue;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } while (read >= 4096);
        return stringBuilder.toString();
    }

    /* JADX WARNING: Removed duplicated region for block: B:35:0x0065 A:{SYNTHETIC, Splitter:B:35:0x0065} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x006f A:{SYNTHETIC, Splitter:B:40:0x006f} */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x007f A:{SYNTHETIC, Splitter:B:49:0x007f} */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x0089 A:{SYNTHETIC, Splitter:B:54:0x0089} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x0093  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x0065 A:{SYNTHETIC, Splitter:B:35:0x0065} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x006f A:{SYNTHETIC, Splitter:B:40:0x006f} */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x0065 A:{SYNTHETIC, Splitter:B:35:0x0065} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x006f A:{SYNTHETIC, Splitter:B:40:0x006f} */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x007f A:{SYNTHETIC, Splitter:B:49:0x007f} */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x0089 A:{SYNTHETIC, Splitter:B:54:0x0089} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x0093  */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x007f A:{SYNTHETIC, Splitter:B:49:0x007f} */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x0089 A:{SYNTHETIC, Splitter:B:54:0x0089} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x0093  */
    /* JADX WARNING: Missing block: B:44:0x0077, code skipped:
            if (r1 != null) goto L_0x0046;
     */
    public static java.lang.String d(java.lang.String r5) {
        /*
        r0 = 0;
        r1 = java.lang.Runtime.getRuntime();	 Catch:{ Exception -> 0x005c, all -> 0x0058 }
        r2 = "sh";
        r1 = r1.exec(r2);	 Catch:{ Exception -> 0x005c, all -> 0x0058 }
        r2 = new java.io.BufferedOutputStream;	 Catch:{ Exception -> 0x0055, all -> 0x0052 }
        r3 = r1.getOutputStream();	 Catch:{ Exception -> 0x0055, all -> 0x0052 }
        r2.<init>(r3);	 Catch:{ Exception -> 0x0055, all -> 0x0052 }
        r3 = new java.io.BufferedInputStream;	 Catch:{ Exception -> 0x004f, all -> 0x004c }
        r4 = r1.getInputStream();	 Catch:{ Exception -> 0x004f, all -> 0x004c }
        r3.<init>(r4);	 Catch:{ Exception -> 0x004f, all -> 0x004c }
        r5 = r5.getBytes();	 Catch:{ Exception -> 0x004a }
        r2.write(r5);	 Catch:{ Exception -> 0x004a }
        r5 = 10;
        r2.write(r5);	 Catch:{ Exception -> 0x004a }
        r2.flush();	 Catch:{ Exception -> 0x004a }
        r2.close();	 Catch:{ Exception -> 0x004a }
        r1.waitFor();	 Catch:{ Exception -> 0x004a }
        r0 = c(r3);	 Catch:{ Exception -> 0x004a }
        r2.close();	 Catch:{ IOException -> 0x003a }
        goto L_0x003e;
    L_0x003a:
        r5 = move-exception;
        r5.printStackTrace();
    L_0x003e:
        r3.close();	 Catch:{ IOException -> 0x0042 }
        goto L_0x0046;
    L_0x0042:
        r5 = move-exception;
        r5.printStackTrace();
    L_0x0046:
        r1.destroy();
        goto L_0x007a;
    L_0x004a:
        r5 = move-exception;
        goto L_0x0060;
    L_0x004c:
        r5 = move-exception;
        r3 = r0;
        goto L_0x007c;
    L_0x004f:
        r5 = move-exception;
        r3 = r0;
        goto L_0x0060;
    L_0x0052:
        r5 = move-exception;
        r3 = r0;
        goto L_0x007d;
    L_0x0055:
        r5 = move-exception;
        r2 = r0;
        goto L_0x005f;
    L_0x0058:
        r5 = move-exception;
        r1 = r0;
        r3 = r1;
        goto L_0x007d;
    L_0x005c:
        r5 = move-exception;
        r1 = r0;
        r2 = r1;
    L_0x005f:
        r3 = r2;
    L_0x0060:
        r5.printStackTrace();	 Catch:{ all -> 0x007b }
        if (r2 == 0) goto L_0x006d;
    L_0x0065:
        r2.close();	 Catch:{ IOException -> 0x0069 }
        goto L_0x006d;
    L_0x0069:
        r5 = move-exception;
        r5.printStackTrace();
    L_0x006d:
        if (r3 == 0) goto L_0x0077;
    L_0x006f:
        r3.close();	 Catch:{ IOException -> 0x0073 }
        goto L_0x0077;
    L_0x0073:
        r5 = move-exception;
        r5.printStackTrace();
    L_0x0077:
        if (r1 == 0) goto L_0x007a;
    L_0x0079:
        goto L_0x0046;
    L_0x007a:
        return r0;
    L_0x007b:
        r5 = move-exception;
    L_0x007c:
        r0 = r2;
    L_0x007d:
        if (r0 == 0) goto L_0x0087;
    L_0x007f:
        r0.close();	 Catch:{ IOException -> 0x0083 }
        goto L_0x0087;
    L_0x0083:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x0087:
        if (r3 == 0) goto L_0x0091;
    L_0x0089:
        r3.close();	 Catch:{ IOException -> 0x008d }
        goto L_0x0091;
    L_0x008d:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x0091:
        if (r1 == 0) goto L_0x0096;
    L_0x0093:
        r1.destroy();
    L_0x0096:
        throw r5;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.h.a.m0.r.a.d(java.lang.String):java.lang.String");
    }

    public static String e(String str, String str2, String str3) {
        try {
            byte[] bytes = c.b.a.a.a.E(str, "|", str2).getBytes();
            byte[] bytes2 = str3.getBytes();
            str3 = "HmacSHA1";
            SecretKeySpec secretKeySpec = new SecretKeySpec(bytes2, str3);
            Mac instance = Mac.getInstance(str3);
            instance.init(secretKeySpec);
            return Base64.encodeToString(instance.doFinal(bytes), 2);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String f(byte[] bArr) {
        if (bArr == null) {
            return null;
        }
        char[] toCharArray = "0123456789abcdef".toCharArray();
        char[] cArr = new char[(bArr.length * 2)];
        for (int i = 0; i < bArr.length; i++) {
            int i2 = bArr[i] & ISdkLite.REGION_UNSET;
            int i3 = i * 2;
            cArr[i3] = toCharArray[i2 >>> 4];
            cArr[i3 + 1] = toCharArray[i2 & 15];
        }
        return new String(cArr);
    }

    public static void g() {
        i j = i.j();
        Context a = y.a();
        Objects.requireNonNull(j);
        Objects.requireNonNull(c.j.a.d.b.e.i.a(a));
        d b = d.b();
        Objects.requireNonNull(b);
        SparseArray sparseArray = new SparseArray();
        p a2 = q.a(false);
        List list = null;
        String str = "application/vnd.android.package-archive";
        List j2 = a2 != null ? a2.j(str) : null;
        p a3 = q.a(true);
        if (a3 != null) {
            list = a3.j(str);
        }
        ArrayList arrayList = (ArrayList) b.c(j2, list, sparseArray);
        if (arrayList.size() > 0) {
            for (int i = 0; i < arrayList.size(); i++) {
                c cVar = (c) arrayList.get(i);
                File file = new File(cVar.k0(), cVar.l0());
                long lastModified = file.lastModified();
                long b2 = ((long) c.j.a.d.b.l.a.d(cVar.g0()).b("download_file_expire_hours", 0)) * 3600000;
                if (b2 <= 0) {
                    b2 = 604800000;
                }
                if (file.isFile() && file.exists() && System.currentTimeMillis() - lastModified >= b2) {
                    k(file);
                    c.j.a.d.b.e.i.a(y.a()).m(cVar.g0());
                }
            }
        }
    }

    public static void h(Context context) {
        if (context != null) {
            File externalCacheDir = context.getExternalCacheDir();
            if (externalCacheDir != null) {
                try {
                    l(externalCacheDir.getPath());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void i(c cVar, long j, String str, String str2) {
        String str3 = "User-Agent";
        if (y.e != null) {
            String optString = y.t().optString("upload_secret_key");
            if (!TextUtils.isEmpty(optString)) {
                try {
                    HashMap hashMap = new HashMap();
                    if (y.h == null) {
                        y.h = new c.j.a.a.a.e.a(new c.j.a.a.a.e.a.a());
                    }
                    String str4 = y.h.a;
                    hashMap.put("from", str4);
                    String valueOf = String.valueOf(System.currentTimeMillis());
                    hashMap.put("timestamp", valueOf);
                    hashMap.put("signature", e(str4, valueOf, optString));
                    JSONObject jSONObject = new JSONObject();
                    jSONObject.put("ad_id", j);
                    jSONObject.put("log_extra", str);
                    jSONObject.put("download_url", cVar.d);
                    JSONObject jSONObject2 = new JSONObject();
                    jSONObject2.put("app_name", cVar.j0());
                    jSONObject2.put("package_name", str2);
                    jSONObject2.put("package_size", cVar.T);
                    List<e> list = cVar.i;
                    if (list != null && !list.isEmpty()) {
                        for (e eVar : list) {
                            if (TextUtils.equals(eVar.a, str3)) {
                                jSONObject2.put(str3, eVar.b);
                                break;
                            }
                        }
                    }
                    jSONObject.put("request_info", jSONObject2.toString());
                    hashMap.put("info", jSONObject.toString());
                    c.j.a.c.o.a.a.c(new c.j.a.c.g$o.a(hashMap));
                } catch (Exception unused) {
                }
            }
        }
    }

    public static void j(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (IOException unused) {
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x0031 A:{SYNTHETIC, Splitter:B:21:0x0031} */
    public static void k(java.io.File r3) {
        /*
        r0 = 0;
        r1 = new java.io.FileOutputStream;	 Catch:{ Exception -> 0x001a, all -> 0x0018 }
        r1.<init>(r3);	 Catch:{ Exception -> 0x001a, all -> 0x0018 }
        r0 = "1";
        r0 = r0.getBytes();	 Catch:{ Exception -> 0x0016 }
        r1.write(r0);	 Catch:{ Exception -> 0x0016 }
        r1.close();	 Catch:{ Exception -> 0x0016 }
        goto L_0x002b;
    L_0x0013:
        r3 = move-exception;
        r0 = r1;
        goto L_0x002f;
    L_0x0016:
        r0 = move-exception;
        goto L_0x001e;
    L_0x0018:
        r3 = move-exception;
        goto L_0x002f;
    L_0x001a:
        r1 = move-exception;
        r2 = r1;
        r1 = r0;
        r0 = r2;
    L_0x001e:
        r0.printStackTrace();	 Catch:{ all -> 0x0013 }
        if (r1 == 0) goto L_0x002b;
    L_0x0023:
        r1.close();	 Catch:{ Exception -> 0x0027 }
        goto L_0x002b;
    L_0x0027:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x002b:
        r3.delete();
        return;
    L_0x002f:
        if (r0 == 0) goto L_0x0039;
    L_0x0031:
        r0.close();	 Catch:{ Exception -> 0x0035 }
        goto L_0x0039;
    L_0x0035:
        r0 = move-exception;
        r0.printStackTrace();
    L_0x0039:
        throw r3;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.h.a.m0.r.a.k(java.io.File):void");
    }

    public static void l(String str) {
        File file = new File(str);
        if (!file.exists()) {
            return;
        }
        if (file.isFile()) {
            file.delete();
            return;
        }
        String[] list = file.list();
        if (list != null) {
            for (String str2 : list) {
                String str22;
                if (str22 != null) {
                    String str3 = File.separator;
                    if (str.endsWith(str3)) {
                        str22 = c.b.a.a.a.D(str, str22);
                    } else {
                        str22 = c.b.a.a.a.E(str, str3, str22);
                    }
                    File file2 = new File(str22);
                    if (file2.isFile()) {
                        file2.delete();
                    }
                    if (file2.isDirectory()) {
                        l(str22);
                    }
                }
            }
            file.delete();
        }
    }

    public static void m(ZipFile zipFile) {
        if (zipFile != null) {
            try {
                zipFile.close();
            } catch (IOException unused) {
            }
        }
    }

    public static boolean n(c.j.a.a.a.c.d dVar) {
        return dVar.t() && (dVar instanceof c.j.a.b.a.a.c) && dVar.B() == 1;
    }

    public static boolean o(c.j.a.d.b.l.a aVar, String str) {
        return (aVar == null || aVar.b("apk_update_handler_enable", 1) != 1) ? false : "application/ttpatch".equals(str);
    }

    @SuppressLint({"PrivateApi"})
    public static Application p() {
        try {
            return (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication", new Class[0]).invoke(null, null);
        } catch (Throwable unused) {
            return null;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:40:0x00be  */
    public static void q() {
        /*
        r0 = c.j.a.c.g.y.a();
        r0 = c.j.a.d.b.e.i.a(r0);
        r1 = "application/vnd.android.package-archive";
        r0 = r0.h(r1);
        r0 = (java.util.ArrayList) r0;
        r1 = r0.isEmpty();
        if (r1 == 0) goto L_0x0017;
    L_0x0016:
        return;
    L_0x0017:
        r1 = 0;
        r2 = 0;
    L_0x0019:
        r3 = r0.size();
        if (r2 >= r3) goto L_0x00c8;
    L_0x001f:
        r3 = r0.get(r2);
        r3 = (com.ss.android.socialbase.downloader.g.c) r3;
        if (r3 == 0) goto L_0x00c4;
    L_0x0027:
        r4 = new java.lang.StringBuilder;
        r4.<init>();
        r5 = r3.e;
        r4.append(r5);
        r5 = java.io.File.separator;
        r4.append(r5);
        r5 = r3.b;
        r4.append(r5);
        r4 = r4.toString();
        r5 = new java.io.File;
        r5.<init>(r4);
        r6 = r5.exists();
        if (r6 == 0) goto L_0x00c4;
    L_0x004a:
        r6 = java.lang.System.currentTimeMillis();
        r8 = r5.lastModified();
        r6 = r6 - r8;
        r3 = r3.g0();
        r3 = c.j.a.d.b.l.a.d(r3);
        r8 = "download_complete_file_expire_hours";
        r3 = r3.b(r8, r1);
        r8 = (long) r3;
        r10 = 3600000; // 0x36ee80 float:5.044674E-39 double:1.7786363E-317;
        r8 = r8 * r10;
        r10 = 0;
        r3 = (r8 > r10 ? 1 : (r8 == r10 ? 0 : -1));
        if (r3 > 0) goto L_0x0070;
    L_0x006d:
        r8 = 604800000; // 0x240c8400 float:3.046947E-17 double:2.988109026E-315;
    L_0x0070:
        r3 = 1;
        r10 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1));
        if (r10 < 0) goto L_0x0076;
    L_0x0075:
        goto L_0x00bf;
    L_0x0076:
        r6 = c.j.a.c.g.y.a();
        if (r6 == 0) goto L_0x00ba;
    L_0x007c:
        if (r4 == 0) goto L_0x00ba;
    L_0x007e:
        r7 = android.text.TextUtils.isEmpty(r4);
        if (r7 == 0) goto L_0x0085;
    L_0x0084:
        goto L_0x00ba;
    L_0x0085:
        r7 = new java.io.File;	 Catch:{ Exception -> 0x00b6 }
        r7.<init>(r4);	 Catch:{ Exception -> 0x00b6 }
        r4 = r7.exists();	 Catch:{ Exception -> 0x00b6 }
        if (r4 == 0) goto L_0x00ba;
    L_0x0090:
        r4 = r6.getPackageManager();	 Catch:{ Exception -> 0x00b6 }
        r7 = r7.getAbsolutePath();	 Catch:{ Exception -> 0x00b6 }
        r4 = r4.getPackageArchiveInfo(r7, r1);	 Catch:{ Exception -> 0x00b6 }
        if (r4 != 0) goto L_0x009f;
    L_0x009e:
        goto L_0x00ba;
    L_0x009f:
        r7 = r4.packageName;	 Catch:{ Exception -> 0x00b6 }
        r4 = r4.versionCode;	 Catch:{ Exception -> 0x00b6 }
        r6 = r6.getPackageManager();	 Catch:{ NameNotFoundException -> 0x00ac }
        r6 = r6.getPackageInfo(r7, r1);	 Catch:{ NameNotFoundException -> 0x00ac }
        goto L_0x00ad;
    L_0x00ac:
        r6 = 0;
    L_0x00ad:
        if (r6 != 0) goto L_0x00b0;
    L_0x00af:
        goto L_0x00ba;
    L_0x00b0:
        r6 = r6.versionCode;	 Catch:{ Exception -> 0x00b6 }
        if (r4 > r6) goto L_0x00ba;
    L_0x00b4:
        r4 = 1;
        goto L_0x00bb;
    L_0x00b6:
        r4 = move-exception;
        r4.printStackTrace();
    L_0x00ba:
        r4 = 0;
    L_0x00bb:
        if (r4 == 0) goto L_0x00be;
    L_0x00bd:
        goto L_0x00bf;
    L_0x00be:
        r3 = 0;
    L_0x00bf:
        if (r3 == 0) goto L_0x00c4;
    L_0x00c1:
        k(r5);
    L_0x00c4:
        r2 = r2 + 1;
        goto L_0x0019;
    L_0x00c8:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.h.a.m0.r.a.q():void");
    }

    public static NetworkInfo r() {
        ConnectivityManager connectivityManager = (ConnectivityManager) DeviceInfoApp.c.getSystemService("connectivity");
        return connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
    }

    public static int s(int i) {
        return i == Integer.MAX_VALUE ? 99 : (i + 113) / 2;
    }

    public static int t() {
        TelephonyManager telephonyManager = (TelephonyManager) DeviceInfoApp.c.getSystemService("phone");
        if (telephonyManager == null) {
            return -1;
        }
        CellLocation cellLocation = telephonyManager.getCellLocation();
        if (cellLocation instanceof GsmCellLocation) {
            return ((GsmCellLocation) cellLocation).getCid();
        }
        if (cellLocation instanceof CdmaCellLocation) {
            return ((CdmaCellLocation) cellLocation).getBaseStationId();
        }
        return -1;
    }

    public static DhcpInfo u() {
        WifiManager wifiManager = (WifiManager) DeviceInfoApp.c.getSystemService("wifi");
        if (wifiManager == null) {
            return null;
        }
        return wifiManager.getDhcpInfo();
    }

    /* JADX WARNING: Missing block: B:2:0x0004, code skipped:
            if (r0 != null) goto L_0x0006;
     */
    /* JADX WARNING: Missing block: B:4:0x000a, code skipped:
            if (r0.hasMoreElements() == false) goto L_0x0037;
     */
    /* JADX WARNING: Missing block: B:5:0x000c, code skipped:
            r1 = ((java.net.NetworkInterface) r0.nextElement()).getInetAddresses();
     */
    /* JADX WARNING: Missing block: B:7:0x001a, code skipped:
            if (r1.hasMoreElements() == false) goto L_0x0006;
     */
    /* JADX WARNING: Missing block: B:8:0x001c, code skipped:
            r2 = (java.net.InetAddress) r1.nextElement();
     */
    /* JADX WARNING: Missing block: B:9:0x0024, code skipped:
            if ((r2 instanceof java.net.Inet6Address) == false) goto L_0x0016;
     */
    /* JADX WARNING: Missing block: B:11:0x002a, code skipped:
            if (r2.isLoopbackAddress() != false) goto L_0x0016;
     */
    /* JADX WARNING: Missing block: B:13:0x0030, code skipped:
            if (r2.isLinkLocalAddress() != false) goto L_0x0016;
     */
    /* JADX WARNING: Missing block: B:15:0x0036, code skipped:
            return r2.getHostAddress();
     */
    public static java.lang.String v() {
        /*
        r0 = java.net.NetworkInterface.getNetworkInterfaces();	 Catch:{ SocketException -> 0x0037 }
        if (r0 == 0) goto L_0x0037;
    L_0x0006:
        r1 = r0.hasMoreElements();	 Catch:{ SocketException -> 0x0037 }
        if (r1 == 0) goto L_0x0037;
    L_0x000c:
        r1 = r0.nextElement();	 Catch:{ SocketException -> 0x0037 }
        r1 = (java.net.NetworkInterface) r1;	 Catch:{ SocketException -> 0x0037 }
        r1 = r1.getInetAddresses();	 Catch:{ SocketException -> 0x0037 }
    L_0x0016:
        r2 = r1.hasMoreElements();	 Catch:{ SocketException -> 0x0037 }
        if (r2 == 0) goto L_0x0006;
    L_0x001c:
        r2 = r1.nextElement();	 Catch:{ SocketException -> 0x0037 }
        r2 = (java.net.InetAddress) r2;	 Catch:{ SocketException -> 0x0037 }
        r3 = r2 instanceof java.net.Inet6Address;	 Catch:{ SocketException -> 0x0037 }
        if (r3 == 0) goto L_0x0016;
    L_0x0026:
        r3 = r2.isLoopbackAddress();	 Catch:{ SocketException -> 0x0037 }
        if (r3 != 0) goto L_0x0016;
    L_0x002c:
        r3 = r2.isLinkLocalAddress();	 Catch:{ SocketException -> 0x0037 }
        if (r3 != 0) goto L_0x0016;
    L_0x0032:
        r0 = r2.getHostAddress();	 Catch:{ SocketException -> 0x0037 }
        return r0;
    L_0x0037:
        r0 = com.liuzh.deviceinfo.DeviceInfoApp.c;
        r1 = 2131690514; // 0x7f0f0412 float:1.9010074E38 double:1.0531950505E-314;
        r0 = r0.getString(r1);
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.h.a.m0.r.a.v():java.lang.String");
    }

    public static int w() {
        TelephonyManager telephonyManager = (TelephonyManager) DeviceInfoApp.c.getSystemService("phone");
        if (telephonyManager == null) {
            return -1;
        }
        CellLocation cellLocation = telephonyManager.getCellLocation();
        if (cellLocation instanceof GsmCellLocation) {
            return ((GsmCellLocation) cellLocation).getLac();
        }
        if (cellLocation instanceof CdmaCellLocation) {
            return ((CdmaCellLocation) cellLocation).getNetworkId();
        }
        return -1;
    }

    public static int x() {
        NetworkInfo r = r();
        int i = 0;
        if (r == null || !r.isAvailable()) {
            return 0;
        }
        int i2 = -1;
        if (r.getType() == 1) {
            i2 = 5;
        } else if (r.getType() == 0) {
            switch (r.getSubtype()) {
                case 1:
                case 2:
                case 4:
                case 7:
                case 11:
                case 16:
                    i = 1;
                    break;
                case 3:
                case 5:
                case 6:
                case 8:
                case 9:
                case 10:
                case 12:
                case 14:
                case 15:
                case 17:
                    i = 2;
                    break;
                case 13:
                case 18:
                    i = 3;
                    break;
                case ModuleDescriptor.MODULE_VERSION /*20*/:
                    i = 4;
                    break;
                default:
                    String subtypeName = r.getSubtypeName();
                    if (!TextUtils.isEmpty(subtypeName)) {
                        if (!(subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000"))) {
                            i = -1;
                            break;
                        }
                        i = 2;
                        break;
                    }
                    break;
            }
            i2 = i;
        }
        return i2;
    }

    public static int y(int i) {
        return (i > 31 || i < 0) ? Integer.MAX_VALUE : (i * 2) - 113;
    }

    public static WifiInfo z() {
        WifiManager wifiManager = (WifiManager) DeviceInfoApp.c.getSystemService("wifi");
        if (wifiManager == null) {
            return null;
        }
        return wifiManager.getConnectionInfo();
    }
}
